//
//  StartView.swift
//  GreenDeal
//
//  Created by Moennig Q on 15/2/2023.
//

import UIKit
import SnapKit
class StartView: View {
    
    
    let toLoginBtn = UIButton()
    override func setUpView() {
        self.backgroundColor = .white
        //loginImageView
        var loginImageViewSize: CGSize = CGSize(width: 311, height: 410)
        if APPConfig.WidthForPortrait == 375 {//375
            loginImageViewSize = CGSize(width: 280, height: loginImageViewSize.height / loginImageViewSize.width * 280)
        }else if APPConfig.WidthForPortrait < 375 {//320
            loginImageViewSize = CGSize(width: 220, height: loginImageViewSize.height / loginImageViewSize.width * 220)
        }
        //back view
        let backView = UIView()
        backView.backgroundColor = .clear
        self.addSubview(backView)
        backView.snp.makeConstraints { (make) in
            make.height.greaterThanOrEqualTo(0)
            make.width.lessThanOrEqualTo(loginImageViewSize.width)
            make.center.equalToSuperview()
        }
        
        //Login imageView
        let loginImageViewWithAppName = UIImageView(image: R.image.login_app_with_appname_icon())
        backView.addSubview(loginImageViewWithAppName)
        loginImageViewWithAppName.snp.makeConstraints { (make) in
            make.top.right.equalToSuperview()
            make.height.equalTo(27)
            make.width.equalTo(110)
        }
        
        let startImageView = UIImageView(image: R.image.start_top_image())
        startImageView.contentMode = .scaleAspectFit
        backView.addSubview(startImageView)
        startImageView.snp.makeConstraints { (make) in
            make.top.equalTo(loginImageViewWithAppName.snp.bottom).offset(10)
            make.left.right.equalToSuperview()
            make.height.equalTo(loginImageViewSize.height)
        }
        //
        let titleLabel = ContentLabel(R.font.interSemiBold(size: 32),hexStr: "#000000FF")
        titleLabel.text = "Great Installation Job, Right Now."
        titleLabel.numberOfLines = 2
        titleLabel.textAlignment = .left
        titleLabel.adjustsFontSizeToFitWidth = true
        backView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
            make.top.equalTo(startImageView.snp.bottom).offset(10)
            make.left.right.equalTo(startImageView)
            make.height.greaterThanOrEqualTo(0)
            
        }
        //
        toLoginBtn.setImage(R.image.start_tologin_btn(), for: UIControl.State.normal)
        backView.addSubview(toLoginBtn)
        toLoginBtn.snp.makeConstraints { make in
            make.top.equalTo(titleLabel.snp.bottom).offset(20)
            make.height.width.equalTo(58)
            make.right.bottom.equalToSuperview()
        }
    }

}
